package manager;
import java.util.Set;

import entity.User;
import entity.state.user.ActiveState;
import entity.state.user.UserState;

import java.util.ArrayList;
import java.util.List;


public class UserManager {

	private List<User> users = new ArrayList<User>();
	
	private static UserManager instance;
	
	public static UserManager getInstance() {
		if (instance == null) {
			instance = new UserManager();
		}
		return instance;
	}
	
	private UserManager(){
		addUser("Florian", "Pusch", 0, new ActiveState()); //wenn wir den hier auf aktiv setzen sind die user immer active
		addUser("Andreas", "Kutschmann", 1, new ActiveState());
	}

	public List<User> findAll(){
		return users;
	}
	
	public User findById(int id) {
		for (User user: users) {
			if (id == user.getUserId()) {
				return user;
			}
		}
		return null;
	}
	
	public void addUser(String vorName, String nachName, int userId, UserState userState) {
		User user = new User();
		user.setUserId(userId);
		user.setVorName(vorName);
		user.setNachName(nachName);
        user.setUserState(new ActiveState());                
		users.add(user);
	}

}
